<?php

namespace Controller\User;

class Upload extends Base {

	public function actionIndex() {
		$config = array(
			'savePath' => 'upload/',             //存储文件夹
			'maxSize' => 102400 ,                   //允许的文件最大尺寸，单位KB
			'allowFiles' => array('.gif' , '.png' , '.jpg' , '.jpeg')  //允许的文件格式
		);
		//上传文件目录
		$fileName = '';
		$error = '';
		$info = false;
		if ($_FILES) {
			$up = new \Util\Uploader('upfile', $config);
			$info = $up->getFileInfo();
			if ($info['state'] == 'SUCCESS') {
				$fileName = $info['url'];
			} else {
				$error = $info['state'];
			}
			$info = array(
				'fileName' => $fileName,
				'error' => $error,
			);
		}
		$this->assign('info', $info);
		$this->display();
	}
}